<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <script src="main.js" defer></script>
  <style>
    .chartWrapper {
      position: absolute;
      left: 0;
      top: 600px;
    }

    .chart {
      width: 600px;
      height: 400px;
      position: relative;

    }
  </style>
</head>

<body>
  <!-- 为 ECharts 准备一个定义了宽高的 DOM -->

  <h1>Life cycle callbacks test</h1>

  <div>
    <button class="add">Add custom-square to DOM</button>
    <button class="update">Update attributes</button>
    <button class="remove">Remove custom-square from DOM</button>
  </div>

  <!-- <my-chart class="my-chart">
  </my-chart> -->

  <div class="chartWrapper">
    <div class="chart"></div>

  </div>

  <script src="./echarts.js"></script>
  <script src="./*.js"></script>
  <script>

    const dom = document.querySelector('.chart');
    const myChart = echarts.init(dom, 'vintage');

    // 指定图表的配置项和数据
    var option = {
      title: {
        text: 'ECharts 入门示例'
      },
      tooltip: {},
      legend: {
        data: ['销量']
      },
      xAxis: {
        data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
      },
      yAxis: {},
      series: [
        {
          name: '销量',
          type: 'bar',
          data: [5, 20, 36, 10, 10, 20]
        }
      ]
    };

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);


    const mySquare = document.querySelector('.chart');
    setInterval(function () {
      option.title.text=Math.floor(Math.random()*10);
      let temp = option.series[0].data;
      console.error(`temp`, temp);
      temp.forEach((element, index) => {
        temp[index] += 2;
      });
    myChart.setOption(option);

      // mySquare.setAttribute('option', JSON.stringify(option));


    }, 5000)

  </script>
</body>

</html>